﻿using System;
using System.Data;
using System.Windows.Forms;
using NDK.Module.DAL;

namespace NDK.Frm
{
    public partial class Frm_CheckRoiRecord : Form
    {

        private UserFPInfoServices userFPInfoServices = new UserFPInfoServices();
        
        public Frm_CheckRoiRecord()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 窗体对象实例，单例模式,保证整个工程只有一个实例
        /// </summary>
        private static Frm_CheckRoiRecord _instance;
        private static readonly object singletonLock = new object();
        public static Frm_CheckRoiRecord Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (singletonLock)
                    {
                        if (_instance == null)
                        {
                            _instance = new Frm_CheckRoiRecord();
                        }
                    }
                }
                return _instance;
            }
        }

        private void Frm_CheckRoiRecord_Load(object sender, EventArgs e)
        {

        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            string startTime = dateTimePicker1.Value.ToString("yyyy-MM-dd 00:00:00");
            string endTime = dateTimePicker2.Value.ToString("yyyy-MM-dd 23:59:59");

            DataSet dataSet = userFPInfoServices.InquirySpecifyTime2Table(startTime, endTime, "ModifyROI", "Time");

            if (dataSet.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                {
                    dataGridView1.Rows.Add();

                    string ModifiedUserName = dataSet.Tables[0].Rows[i]["UserName"].ToString();
                    string ModifiedROI = dataSet.Tables[0].Rows[i]["ModifyROI"].ToString();

                    string[] ModifyFAI = new string[4];
                    ModifyFAI = ModifiedROI.Split('|');

                    string ROI_Modified = "";

                    foreach (string Item_FAI in ModifyFAI)
                    {
                        ROI_Modified = ROI_Modified + Item_FAI.Replace(",", "-->") + "  ";
                    }

                    string ModifiedTime = dataSet.Tables[0].Rows[i]["Time"].ToString();

                    dataGridView1.Rows[i].Cells[0].Value = ModifiedTime;
                    dataGridView1.Rows[i].Cells[1].Value = ROI_Modified;// ModifiedUserName;
                    dataGridView1.Rows[i].Cells[2].Value = ModifiedUserName;//
                    //  dataGridView1.Rows[i].Cells[3].Value = "SystemConfigChanged";

                }
            }
            else
            {
                MessageBox.Show(this, "该时间段无更改记录!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }

        }
    }
}
